﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace GameLogicProject
{
    class OptionType
    {
        public string Name { get; set; }
        public int Influence { get; set; }
        public Option Choice { get; set; }
        //Options
        public ArrayList Options { get; set; }
        //Next OptionType 
        public ArrayList OptionTypes { get; set; }

        public ArrayList talksGenerated { get; set; }

        public OptionType(string name, int influence)
        {
            this.Name = name;
            this.Influence = influence;
        }

        public static void processOptionType(OptionType root, int numTalks)
        {
            root.talksGenerated = root.Choice.getTalksFromChoice(numTalks);

            foreach (OptionType optType in root.OptionTypes)
            {
                processOptionType(optType, numTalks);
            }

        }


        public static int generateFinalPercentage(OptionType root)
        {
            int finalPercentage = 0;

            finalPercentage += (root.Influence * root.Choice.Percentage) / 100;

            foreach (OptionType optType in root.OptionTypes)
            {
                finalPercentage += OptionType.generateIncome(optType);
            }

            return finalPercentage;
        }



        /*
        public ArrayList getTalksFromOptions(OptionType optType, int numTalks)
        {
            ArrayList percentages = new ArrayList();
            ArrayList generatedTalks = new ArrayList();

            int total = 0;
            foreach (Option opt in optType.Options)
            {
                total += opt.Percentage;
                percentages.Add(total);
            }

            Random rand = new Random();
            int generateNumber = 0;

            for (int i = 0; i < numTalks; i++)
            {
                generateNumber = rand.Next(total);

                int optionTalk = -1;
                for (int perc = 0; i < percentages.Count; i++ )
                {
                    if (generateNumber < perc)
                    {
                        optionTalk = i;
                        break;
                    }
                }

                generateNumber = rand.Next(((Option)optType.Options[i]).Talks.Count);

                generatedTalks.Add(((Option)optType.Options[i]).Talks[generateNumber]);
            }

            return null;
        }*/

    }
}
